<?php
/**
 + Created by:	Webit Solution
 * Company:		Webit Solution
 + Contact:		www.webitsolution.com , info@webitsolution.com
				www.webitsolution.com, developer@webitsolution.com
 * Created on:	Nov 29, 2012
 ^
 + Project: 		WRecruit 
 * File Name:	module/jsgoldresume.php
 ^ 
 * Description: Module for WRecruit
 ^ 
 * History:		NONE
 ^ 
 */

defined('_JEXEC') or die('Restricted access');

$noofresumes = $params->get('noofresumes');
$noofcols = $params->get('noofcols');
$listingstyle = $params->get('listingstyle');
$title = $params->get('title');
$shtitle = $params->get('shtitle');
$applicationtitle = $params->get('applicationtitle');
$name = $params->get('name');
$category= $params->get('category');
$jobtype = $params->get('jobtype');
$experience = $params->get('experience');
$available = $params->get('available');
$gender = $params->get('gender');
$nationality = $params->get('nationality');
$showlocation= $params->get('location');
$posteddate= $params->get('posteddate');
$separator= $params->get('separator');

$sliding= $params->get('sliding','1');
$consecutivesliding= $params->get('consecutivesliding','3');

$photo= $params->get('photo');
$photowidth= $params->get('photowidth');
$photoheight= $params->get('photoheight');

$theme = $params->get('theme', 1);

$totalcols = 0;
if ($applicationtitle == 1) $totalcols++;
if ($name == 1)$totalcols++;
if ($category == 1)$totalcols++;
if ($jobtype == 1)$totalcols++;
if ($experience == 1)$totalcols++;
if ($available == 1)$totalcols++;
if ($gender == 1)$totalcols++;
if ($nationality == 1)$totalcols++;
if ($showlocation == 1)$totalcols++;
if ($posteddate == 1)$totalcols++;

$colwidth = round(100 / $noofcols);


//scs				
if($params->get('Itemid')) $itemid = $params->get('Itemid');			
else $itemid =  JRequest::getVar('Itemid');
//sce

// Language variable start
$applicationtitlecaption = JText::_('JS_TITLE');
$nametitle = JText::_('JS_NAME');
$categorytitle = JText::_('JS_CATEGORY');
$jobtypetitle = JText::_('JS_WORK_PREFERENCE');
$experiencetitle = JText::_('JS_EXPERIENCE');
$availabletitle = JText::_('JS_AVAILABLITY');
$gendertitle = JText::_('JS_GENDER');
$nationalitytitle = JText::_('JS_NATIONALITY');
$locationtitle = JText::_('JS_LOCATION');
$postedtitle = JText::_('JS_POSTED');
$yes = JText::_('JS_YES');
$no = JText::_('JS_NO');
$male = JText::_('JS_MALE');
$female = JText::_('JS_FEMALE');
// Language variable end
/** scs */
$componentAdminPath = JPATH_ADMINISTRATOR . DS . 'components' . DS . 'com_wrecruit';
$componentPath =  'components' . DS . 'com_wrecruit';
require_once $componentPath . DS . 'models' . DS . 'mpwrecruit.php';
$config = array( 'table_path' => $componentAdminPath . DS . 'tables');
$model = new WRecruitModelMpWRecruit($config);
$result = $model->getGoldResumes($noofresumes,$theme);
$resumes = $result[0];
$trclass = $result[1];	
$dateformat = $result[2];	
$contents = '';
/** sce */

if (isset($resumes)) { 
	if($listingstyle == 1){ //vertical listing
	
			
		$contents .= '<table cellpadding="0" cellspacing="0" border="0" width="100%" class="contentpane">';
		$isodd = 1;
		foreach($resumes as $resume)	{ 
			$isodd = 1 - $isodd;

			if ($shtitle == 1){
				$top =  '<tr class="'.$trclass[$isodd].'">';
				$top .=  '<td colspan="'.$noofcols.'">';
				$top .=  '<h2><u>'.$title.'</u></h2>';	
				$top .= '</td>';
				$top .= '</tr>';
			}	
			
			$contents .= '<tr class="'.$trclass[$isodd].'"><td>';
			if ($applicationtitle == 1) $contents .=  '<small>'.$applicationtitlecaption.': <a href="index.php?option=com_wrecruit&c=wrecruit&view=jobseeker&layout=view_resume&vm=3&rd='. $resume->id . '&Itemid='.$itemid.'">'.$resume->application_title.'</a></small><br>';
			if ($name == 1) $contents .=  '<small>'.$nametitle.': <a href="index.php?option=com_wrecruit&c=wrecruit&view=jobseeker&layout=view_resume&vm=3&rd='. $resume->id . '&Itemid='.$itemid.'">'.$resume->first_name.' '.$resume->last_name.'</a></small><br>';
			if ($category == 1)$contents .=  '<small >'.$categorytitle.' : '.$resume->cat_title.'</small><br>';
			if ($jobtype == 1)$contents .= '<small >'.$jobtypetitle.' : '.$resume->jobtypetitle.'</small><br>';
			if ($experience == 1)$contents .=  '<small>'.$experiencetitle.' : '.$resume->total_experience.'</small><br>';
			if ($available == 1) if($resume->iamavailable == 1) $contents .=  '<small>'.$availabletitle.' : '.$yes.'</small><br>'; else $contents .=  '<small>'.$availabletitle.' : '.$no.'</small><br>';
			if ($gender == 1) if($resume->gender == 1) $contents .=  '<small>'.$gendertitle.' : '.$male.'</small><br>'; else $contents .=  '<small>'.$gendertitle.' : '.$female.'</small><br>';
			if ($nationality == 1)$contents .= '<small>'.$nationalitytitle.' : '.$resume->nationalityname.'</small><br>';
			if ($showlocation == 1){
					if($resume->cityname) $location = $resume->cityname;
					elseif($resume->address_city) $location = $resume->address_city;
					elseif($resume->countyname) $location = $resume->countyname;
					elseif($resume->address_county) $location = $resume->address_county;
					elseif($resume->statename) $location = $resume->statename;
					elseif($resume->address_state) $location = $resume->address_state;
					elseif($resume->countryname) $location = $resume->countryname;
				if(isset($location))
				$contents .= '<small>'.$locationtitle.': '.$location.'</small><br />';
			}	
			if ($posteddate == 1) $contents .= "<small>".$postedtitle.": ".date($dateformat,strtotime($resume->create_date))."</small><br /><br />";
			if ($separator == 1) $contents .= '<hr style="border:dashed #C0C0C0; border-width:1px 0 0 0; height:0;line-height:0px;font-size:0;margin:0;padding:0;">';
			$contents .= '</td></tr>';
		}
		$contents .= '</table>';
		
		if ($sliding == 1) {
			for ($a = 0; $a < $consecutivesliding; $a++){
				$contents .= $contents;
				}
			$contents =  '<marquee  direction="up" scrollamount="2" onmouseover="this.stop();" onmouseout="this.start()";>'.$contents.'</marquee>';
			$contents =$top.$contents.'<br clear="all">';
		}
		
		
		
	}else{ // horizontal listing
		$contents =  '<table cellpadding="0" cellspacing="0" border="0" width="100%" class="contentpane">';
			$isodd = 1;

					if ($shtitle == 1){
						$contents .=  '<tr class="'.$trclass[$isodd].'">';
						$contents .=  '<td  height="25" class="'.$trclass[$isodd].'" colspan="'.$totalcols.'" align="center">'. $title.'</td>';
						$contents .=  '</tr><tr><td colspan="'.$totalcols.'" height="2"></td></tr>';
					}	
					$contents .=  '<tr class="'.$trclass[$isodd].'">';
						if ($applicationtitle == 1)$contents .=  '<th align="center" width="20%">'.$applicationtitlecaption.'</th>';
						if ($name == 1)$contents .=  '<th align="center" width="20%">'.$nametitle.'</th>';
						if ($category == 1)$contents .=  '<th align="center" width="20%">'.$categorytitle.'</th>';
						if ($jobtype == 1)$contents .=  '<th align="center" width="20%">'.$jobtypetitle.'</th>';
						if ($experience == 1)$contents .=  '<th align="center" width="20%">'.$experiencetitle.'</th>';
						if ($available == 1)$contents .=  '<th align="center" width="15%">'.$availabletitle.'</th>';
						if ($gender == 1)$contents .=  '<th align="center" width="15%">'.$gendertitle.'</th>';
						if ($nationality == 1)$contents .=  '<th align="center" width="15%">'.$nationalitytitle.'</th>';
						if ($showlocation == 1)$contents .=  '<th align="center" width="20%">'.$locationtitle.'</th>';
						if ($posteddate == 1)$contents .=  '<th align="center" width="15%">'.$postedtitle.'</th>';
					$contents .=  '</tr>';
					
					foreach($resumes as $resume)	{ 
						$contents .=  '<tr class="'.$trclass[$isodd].'">';
								  
									if ($applicationtitle == 1) $contents .=  '<td ><a href="index.php?option=com_wrecruit&c=wrecruit&view=jobseeker&layout=view_resume&vm=3&rd='. $resume->id . '&Itemid='.$itemid.'">'.$resume->application_title.'</a></td>';
									if ($name == 1) $contents .=  '<td ><a href="index.php?option=com_wrecruit&c=wrecruit&view=jobseeker&layout=view_resume&vm=3&rd='. $resume->id . '&Itemid='.$itemid.'">'.$resume->first_name.' '.$resume->last_name.'</a></td>';
									if ($category == 1)$contents .=  '<td >'.$resume->cat_title.'</td>';
									if ($jobtype == 1)$contents .=  '<td >'.$resume->jobtypetitle.'</td>';
									if ($experience == 1)$contents .=  '<td >'.$resume->total_experience.'</td>';
									if ($available == 1) if($resume->iamavailable == 1) $contents .=  '<td >'.$yes.'</td>'; else $contents .=  '<td >'.$no.'</td>';
									if ($gender == 1) if($resume->gender == 1) $contents .=  '<td >'.$male.'</td>'; else $contents .=  '<td >'.$female.'</td>';
									if ($nationality == 1)$contents .=  '<td >'.$resume->nationalityname.'</td>';
									if ($showlocation == 1){
										$contents .=  '<td >';
											if($resume->cityname) $location = $resume->cityname;
											elseif($resume->address_city) $location = $resume->address_city;
											elseif($resume->countyname) $location = $resume->countyname;
											elseif($resume->address_county) $location = $resume->address_county;
											elseif($resume->statename) $location = $resume->statename;
											elseif($resume->address_state) $location = $resume->address_state;
											elseif($resume->countryname) $location = $resume->countryname;
										if(isset($location)) $contents .=  $location;
										$contents .=  '</td>';
									}	
									if ($posteddate == 1)$contents .=  '<td >'.date($dateformat,strtotime($resume->create_date)).'</td>';
									$isodd=1-$isodd ;
						 $contents .=  '</tr>';
					}
			$contents .=  '<tr height="6"></tr>	';
		$contents .=  '</table>	';
		
		$tcontents = '<table cellpadding="0" cellspacing="0" border="1" width="100%" class="contentpane"> <tr>';
		for ($a = 0; $a < $consecutivesliding; $a++){
			$scontents = '<td>'.$contents.'</td>';
		}
		$contents = $tcontents.$scontents.'</tr></table>';
		$contents =  '<marquee  scrollamount="2" onmouseover="this.stop();" onmouseout="this.start()";>'.$contents.'</marquee>';
		
		
	}	
	echo $contents;
		
}
?>

